# Thread线程练习
from threading import Thread
import requests
result=[]
def request_bilibili(index):
    url="https://www.bilibili.com/"
    headers={
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36"
    }
    response=requests.get(url=url,headers=headers)
    print("index is ",index,": ",response.status_code)
    result.append(response)

if __name__=="__main__":
    # print("begin")
    t_arr=[]
    for i in range(5):
        th=Thread(target=request_bilibili,args=(i,))
        t_arr.append(th)
        th.start()
    for t in t_arr:
        t.join()
    print("result is :",result)
    print("end")


# index is  1 :  200
# index is  4 :  200
# index is  0 :  200
# index is  3 :  200
# index is  2 :  200
# end
# result is : [<Response [200]>, <Response [200]>, <Response [200]>, <Response [200]>, <Response [200]>]
# end
